#ifndef __LCD_H
#define __LCD_H

#ifdef __cplusplus
 extern "C" {
#endif

#include "at32f435_437.h"

#define WHITE         	 0xFFFF
#define BLACK         	 0x0000	  
#define BLUE           	 0x001F  
#define BRED             0XF81F
#define GRED 			 0XFFE0
#define GBLUE			 0X07FF
#define RED           	 0xF800
#define MAGENTA       	 0xF81F
#define GREEN         	 0x07E0
#define CYAN          	 0x7FFF
#define YELLOW        	 0xFFE0
#define BROWN 			 0XBC40 //棕色
#define BRRED 			 0XFC07 //棕红色
#define GRAY  			 0X8430 //灰色
#define DARKBLUE      	 0X01CF	//深蓝色
#define LIGHTBLUE      	 0X7D7C	//浅蓝色  
#define GRAYBLUE       	 0X5458 //灰蓝色
#define LIGHTGREEN     	 0X841F //浅绿色
#define LGRAY 			 0XC618 //浅灰色(PANNEL),窗体背景色
#define LGRAYBLUE        0XA651 //浅灰蓝色(中间层颜色)
#define LBBLUE           0X2B12 //浅棕蓝色(选择条目的反色)

#define LCD_BL_EN()		gpio_bits_set(GPIOC,GPIO_PINS_9)
#define LCD_BL_DIS()	gpio_bits_reset(GPIOC,GPIO_PINS_9)
#define LCD_RES_H()		gpio_bits_set(GPIOC,GPIO_PINS_11)
#define LCD_RES_L()		gpio_bits_reset(GPIOC,GPIO_PINS_11)
#define LCD_DC_H()		gpio_bits_set(GPIOC,GPIO_PINS_8)
#define LCD_DC_L()		gpio_bits_reset(GPIOC,GPIO_PINS_8)
#define LCD_CS_H()		gpio_bits_set(GPIOA,GPIO_PINS_15)
#define LCD_CS_L()		gpio_bits_reset(GPIOA,GPIO_PINS_15)

#define USE_HORIZONTAL 2

#if ((USE_HORIZONTAL==0)||(USE_HORIZONTAL==1))
#define LCD_W 240
#define LCD_H 320
#else
#define LCD_W 320
#define LCD_H 240
#endif

uint8_t spi_byte_write(uint8_t data);
void LCD_WR_DATA8(uint8_t dat);
void LCD_WR_DATA(uint16_t dat);
void LCD_WR_REG(uint8_t dat);
void LCD_Address_Set(uint16_t x1,uint16_t y1,uint16_t x2,uint16_t y2);
void LCD_Init(void);

void LCD_Fill(uint16_t xsta,uint16_t ysta,uint16_t xend,uint16_t yend,uint16_t color);//指定区域填充颜色
void LCD_DrawPoint(uint16_t x,uint16_t y,uint16_t color);//在指定位置画一个点
void LCD_DrawLine(uint16_t x1,uint16_t y1,uint16_t x2,uint16_t y2,uint16_t color);//在指定位置画一条线
void LCD_DrawRectangle(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2,uint16_t color);//在指定位置画一个矩形
void Draw_Circle(uint16_t x0,uint16_t y0,uint8_t r,uint16_t color);//在指定位置画一个圆

#ifdef __cplusplus
}
#endif

#endif
